home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
UUPC11QS.ARJ
/
PUSHPOP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-21
|
2KB
|
74 lines
/*--------------------------------------------------------------------*/
/* p u s h p o p . c */
/* */
/* Directory functions for UUPC/extended */
/* */
/* Copyright (c) 1989, 1991 Andrew H. Derbyhshire */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <direct.h>
#include <sys/types.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "pushpop.h"
#define MAXDEPTH 10
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
static char *dirstack[MAXDEPTH];
static depth = 0;
currentfile();
/*--------------------------------------------------------------------*/
/* Change to a directory and push on our stack */
/*--------------------------------------------------------------------*/
void PushDir( char *directory )
{
if ( depth >= MAXDEPTH )
panic();
#ifdef __TURBOC__
dirstack[depth] = getcwd( NULL , FILENAME_MAX );
#else
dirstack[depth] = _getdcwd( 0, NULL , FILENAME_MAX );
#endif
if (dirstack[depth] == NULL )
{
printerr("PushDir");
panic();
}
CHDIR( directory );
depth++;
return;
} /* PushDir */
/*--------------------------------------------------------------------*/
/* Return to a directory saved by PushDir */
/*--------------------------------------------------------------------*/
void PopDir( void )
{
if ( depth == 0 )
panic();
CHDIR( dirstack[--depth] );
free( dirstack[depth] );
return;
} /* PopDir */